Set up an Modbus Slave

Follow the guide Add Module to Apis Hive, but this time select a module of type ApisModbusSlave from the Module type drop down list, name it "ModbusSlave" in this case.

  • After adding the module, select the new module named "ModbusSlave" from theSolution Explorer.

Basic setup, communication interface

The module supports both serial (RTU) and TCP/IP (Modbus TCP) interface, depending on your needs. In the Properties Editor, enter values for:

  1. TCP/IP based server:

    • Comm. type: TCP/IP
    • IP address: The endpoint IP address of your ModbusSlave server
    • Port: The endpoint TCP port of your ModbusSlave server
    • Default Slaveaddress: By default set to 1, do not set it to 0 because current functions of this module do not support broadcast.

  1. Serial communication based server :

    • Comm. type receive : Serial
    • Com port: Com port connected to the slave.
    • BaudRate: Baud rate of your slave serial setup.
    • DataBits: Data bits of your slave serial setup.
    • FlowControl: Handshake of your slave serial setup.
    • Parity: Parity of your slave serial setup.
    • StopBits: Stop bits of your slave serial setup.

Add Items (registers)

Now follow the guide Add Items to a Module, but this time select the Modbus module and add items of one of the register types followed by a recommended address range:

  • Coil (1 - 9999)

  • DiscretesInput (10001 - 19999)

  • InputRegister (30001 - 39999)

  • HoldingRegister (40001 - 49999)

  • Note: If more than 10000 register types are needed, follow up on modbus101 documentation recommendations

Example Holding register:

Assure SrcItemID of your created Holding register Item is pointing to valid register address like "40001", check the Slaveadress and set correct Valuetype of the value in the register of the slave. Attribute SrcItemID also represents the address of the item, for example, the item Holding register is of 2 bytes in size. This means, that there need to be proper increments of the SrcItemID value when it comes to SrcItemID based on the item type and the value it holds.

Trouble shooting

If no connection or data received:

  • Use 3 party terminal application like putty to check if server is sending telegrams
  • Check firewall settings for the port
  • Check network connection to server (ping)